Release 10.1A: OpenEdge Development:
.NET Open Clients


Establishing the connection

To establish a connection to an AppServer, you must instantiate an AppObject. You can create an AppObject using one of the four available constructors.

The following constructor establishes an AppServer connection, with the AppServer information specified in the Connection object (connectObj):

Syntax
public AppObject(Progress.Open4GL.Proxy.Connection connectObj) 

Where AppObject is the name of the AppObject as defined in ProxyGen.

A connection object can be instantiated with one of the constructors documented in the "Connection object" section.

The following constructor establishes an AppServer connection, with the specified AppServer connection information (url), user ID, password, and information required by the AppServer application at connection time:

Syntax
public AppObject(string url, string userid, string password, 
     string appserver-info) 

Where AppObject is the name of the AppObject as defined in ProxyGen.

Note: For an HTTPS connection using the AppServer Internet Adapter (AIA) with the Web server running on the .NET Open Client machine, you must specify the Internet host name (not "localhost") in the url parameter exactly as it appears in the CN field of the Web server certificate.

For more information on the AppServer URL connection parameter format and default connection information, see the sections on connecting to an AppServer using a URL in OpenEdge Application Server: Developing AppServer Applications .

The following constructor establishes an AppServer connection, with the specified user ID, password, and information required by the AppServer application at connection time:

Syntax
public AppObject(string userid, string password, string appserver-info) 

Where AppObject is the name of the AppObject as defined in ProxyGen.

The constructor above uses default AppServer connection information. This constructor defaults the URL to AppServer://localhost:5162/appService, where appService is the AppService setting specified on the General tab of the Generate dialog box in ProxyGen.

The following constructor establishes an AppServer connection, with no specified AppServer information:

Syntax
public AppObject() 

Where AppObject is the name of the AppObject as defined in ProxyGen.

The constructor above uses default AppServer connection information. This defaults the URL to AppServer://localhost:5162/appService, where appService is the AppService setting specified on the General tab of the Generate dialog box in ProxyGen.

Also see the information on connecting to an AppServer in OpenEdge Development: Open Client Introduction and Programming .

Handling connection exceptions

The creation of a connection to an AppServer should be wrapped with exception-handling code to avoid memory leaks and unnecessary allocation of client and server resources. Also, information received from a caught exception can be valuable in tracing and fixing connection errors.

The following is an example of handling connection exceptions:

try  
{ 
   //Create Customer AppObject to connect 
   Customer appObj = new Customer(ConnectObj); 
}  
catch (Progress.Open4GL.Exceptions.ConnectException ex) 
{ 
   MessageBox.Show(ex.ToString()); 
} 
finally 
{ 
   if (appObj != null) 
   { 
      appObj.Dispose(); 
   } 
} 

This example executes the connect in the try block. If there is an exception thrown by the process, the catch block displays the exception message to the user.

The catch block is specifically catching the ConnectException. For more information on .NET Open Client exceptions, see Chapter 6, " Handling Errors."

The finally block ensures that the Dispose() method is called on the AppObject. By putting the Dispose() method in the finally block, you ensure that the connection is closed whether an exception occurs or the connect is successful.

Supported AppServer model

For .NET Open Clients, the supported AppServer operating modes are the session-managed modes of state-aware, state-reset, and stateless, and the session-free mode state-free. For more information, see the discussion of “Session Modes” in the chapter on “Generating Proxies and Web Service Definitions” in the OpenEdge Development: Open Client Introduction and Programming .

To access a session-free AppServer, you must set the proxy property PROGRESS.Session.SessionModel to 1. For more information, see Chapter 5, " Accessing Proxy Properties."


Copyright © 2005 Progress Software Corporation
www.progress.com
Voice: (781) 280-4000
Fax: (781) 280-4095